/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package platforms;

import java.util.Map;
import name.pachler.nio.file.WatchKey;
import java.io.IOException;
import name.pachler.nio.file.Path;
import name.pachler.nio.file.Paths;
import name.pachler.nio.file.WatchService;
import static name.pachler.nio.file.StandardWatchEventKind.*;

/**
 *
 * @author paskud
 */
public abstract class PlatformSupport {
    private static PLATFORM _platformName;
    private static PlatformSupport _platform;
    public enum PLATFORM  { WINDOWS, MAC, LINUX, OTHER };

    static {
        if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {
            _platformName = PLATFORM.MAC;
            _platform = new MacSupport();
        }
        if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
            _platformName = PLATFORM.WINDOWS;
            _platform = new WindowsSupport();
        }
        if (System.getProperty("os.name").toLowerCase().startsWith("linux")) {
            _platformName = PLATFORM.LINUX;
            _platform = new LinuxSupport();
        }
    }

    
    /**
     * @return the _platform
     */
    public static PLATFORM getPlatformName() {
        return _platformName;
    }
    
    /**
     * @return the _platform
     */
    public static PlatformSupport getPlatform() {
        return _platform;
    }
    
    
    public void AddWatchPath(String path, WatchService watcher, Map<WatchKey, String> watchedFolders) {
        Path dir = Paths.get(path);
        try {
            dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
        } catch (IOException x) {
            System.err.println(x);
        }
    }   

}
